/*************************************************************************
	> File Name: P1051.cpp
	> Author: yufangze
	> Mail: 2224590123@qq.com
	> Created Time: 2024-12-23 10:54:35
 ************************************************************************/

#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

typedef struct Stu {
    string name;
    int grade;
    int score;
    string leader;
    string west;
    int cnt;
    int price;
} Stu;

int main() {
    Stu arr[105];
    int n, ind = 0, sum = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> arr[i].name >> arr[i].grade >> arr[i].score;
        cin >> arr[i].leader >> arr[i].west >> arr[i].cnt;
        arr[i].price = 0;
        if (arr[i].grade > 80 && arr[i].cnt >= 1) {
            arr[i].price += 8000;
        }
        if (arr[i].grade > 85 && arr[i].score > 80) {
            arr[i].price += 4000;
        }
        if (arr[i].grade > 90) {
            arr[i].price += 2000;
        }
        if (arr[i].grade > 85 && arr[i].west == "Y") {
            arr[i].price += 1000;
        }
        if (arr[i].score > 80 && arr[i].leader == "Y") {
            arr[i].price += 850;
        }
        if (i && arr[i].price > arr[ind].price) ind = i;
        sum += arr[i].price;
    }
    cout << arr[ind].name << endl;
    cout << arr[ind].price << endl;
    cout << sum << endl;
    return 0;
}
